home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntlb20 / lib / strchr.c < prev    next >
C/C++ Source or Header  |  1990-10-26  |  670b  |  34 lines

  1. /* from Henry Spencer's stringlib */
  2. /* modified by ERS */
  3. #include <string.h>
  4.  
  5. /*
  6.  * strchr - find first occurrence of a character in a string
  7.  */
  8. #ifdef __GNUC__
  9. __asm__(".text; .even; .globl _index; _index:"); /* dept of dirty tricks */
  10. #else
  11. char *
  12. index(s, charwanted)
  13.     const char *s;
  14.     char charwanted;
  15. {
  16.     return strchr(s, charwanted);
  17. }
  18. #endif
  19.  
  20. char *                /* found char, or NULL if none */
  21. strchr(s, charwanted)
  22.     const char *s;
  23.     register char charwanted;
  24. {
  25.     register char c;
  26.  
  27.     /*
  28.      * The odd placement of the two tests is so NUL is findable.
  29.      */
  30.     while ((c = *s++) != charwanted)
  31.         if (c == 0) return NULL;
  32.     return((char *)--s);
  33. }
  34.